package com.example.commons.time;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

public class TimeTools {
    private static final DateTimeFormatter FORMATTER_MSEC = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
    private static final DateTimeFormatter FORMATTER_SEC = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
    private static final DateTimeFormatter FORMATTER_FIFTEEN_MIN = DateTimeFormatter.ofPattern("yyyyMMddHHmm");
    private static final DateTimeFormatter FORMATTER_DAY = DateTimeFormatter.ofPattern("yyyyMMdd");
    private static final DateTimeFormatter FORMATTER_INTERVAL_DAY = DateTimeFormatter.ofPattern("yyyy-MM-dd");
    private static final DateTimeFormatter FORMATTER_MONTHS = DateTimeFormatter.ofPattern("yyyyMM");
    private static final DateTimeFormatter FORMATTER_HOURS = DateTimeFormatter.ofPattern("HH");
    private static final DateTimeFormatter FORMATTER_MIN = DateTimeFormatter.ofPattern("HHmm");
    private static final DateTimeFormatter FORMATTER_DAYS = DateTimeFormatter.ofPattern("dd");
    private static final ZoneId CN_ZONE = ZoneId.of("Asia/Shanghai");
    private static final ZoneId UTC_ZONE = ZoneId.of("UTC");

    public static String getTime() {
        return LocalDateTime.now().format(FORMATTER_SEC);
    }

    public static String getMillisecTime() {
        return LocalDateTime.now().format(FORMATTER_MSEC);
    }
    public static String getDate() {
        return LocalDateTime.now().format(FORMATTER_DAY);
    }
}
